home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / Right_to_L2160308192009.psc / RtoL TreeView / frmRtLTvLv.frm < prev    next >
Text File  |  2009-08-19  |  7KB  |  207 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form Treeview 
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   7995
  6.    ClientLeft      =   60
  7.    ClientTop       =   450
  8.    ClientWidth     =   11880
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    ScaleHeight     =   7995
  12.    ScaleWidth      =   11880
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin MSComctlLib.ImageList ImageList1 
  15.       Left            =   360
  16.       Top             =   5880
  17.       _ExtentX        =   1005
  18.       _ExtentY        =   1005
  19.       BackColor       =   -2147483643
  20.       ImageWidth      =   20
  21.       ImageHeight     =   20
  22.       MaskColor       =   12632256
  23.       _Version        =   393216
  24.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  25.          NumListImages   =   6
  26.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  27.             Picture         =   "frmRtLTvLv.frx":0000
  28.             Key             =   ""
  29.          EndProperty
  30.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  31.             Picture         =   "frmRtLTvLv.frx":0393
  32.             Key             =   ""
  33.          EndProperty
  34.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  35.             Picture         =   "frmRtLTvLv.frx":072C
  36.             Key             =   ""
  37.          EndProperty
  38.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  39.             Picture         =   "frmRtLTvLv.frx":0B7E
  40.             Key             =   ""
  41.          EndProperty
  42.          BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  43.             Picture         =   "frmRtLTvLv.frx":0FD0
  44.             Key             =   ""
  45.          EndProperty
  46.          BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  47.             Picture         =   "frmRtLTvLv.frx":1422
  48.             Key             =   ""
  49.          EndProperty
  50.       EndProperty
  51.    End
  52.    Begin MSComctlLib.ListView ListView1 
  53.       Height          =   7260
  54.       Left            =   120
  55.       TabIndex        =   1
  56.       Top             =   480
  57.       Width           =   5655
  58.       _ExtentX        =   9975
  59.       _ExtentY        =   12806
  60.       LabelWrap       =   -1  'True
  61.       HideSelection   =   -1  'True
  62.       _Version        =   393217
  63.       Icons           =   "ImageList1"
  64.       SmallIcons      =   "ImageList1"
  65.       ColHdrIcons     =   "ImageList1"
  66.       ForeColor       =   -2147483640
  67.       BackColor       =   -2147483643
  68.       BorderStyle     =   1
  69.       Appearance      =   1
  70.       NumItems        =   0
  71.    End
  72.    Begin MSComctlLib.TreeView TreeView1 
  73.       Height          =   7260
  74.       Left            =   5760
  75.       TabIndex        =   0
  76.       Top             =   480
  77.       Width           =   6015
  78.       _ExtentX        =   10610
  79.       _ExtentY        =   12806
  80.       _Version        =   393217
  81.       LineStyle       =   1
  82.       Style           =   7
  83.       ImageList       =   "ImageList1"
  84.       BorderStyle     =   1
  85.       Appearance      =   1
  86.    End
  87.    Begin VB.Label Label1 
  88.       Alignment       =   2  'Center
  89.       Caption         =   "Tree View and List View Right To Left Display"
  90.       BeginProperty Font 
  91.          Name            =   "Arial"
  92.          Size            =   14.25
  93.          Charset         =   0
  94.          Weight          =   400
  95.          Underline       =   0   'False
  96.          Italic          =   0   'False
  97.          Strikethrough   =   0   'False
  98.       EndProperty
  99.       ForeColor       =   &H00000000&
  100.       Height          =   375
  101.       Left            =   120
  102.       TabIndex        =   2
  103.       Top             =   120
  104.       Width           =   11655
  105.    End
  106. End
  107. Attribute VB_Name = "Treeview"
  108. Attribute VB_GlobalNameSpace = False
  109. Attribute VB_Creatable = False
  110. Attribute VB_PredeclaredId = True
  111. Attribute VB_Exposed = False
  112. Private Sub Form_Load()
  113.   
  114.   Dim nd As Node, i As Integer, OldLong As Long
  115.   Dim StrText As String, bkMark As String, FoldType As Integer, strNode As Integer
  116.   
  117.   Call ConnectAccessDb
  118.   Set rs = dbs.OpenRecordset("SELECT * FROM [Tree Table]", dbOpenDynaset)
  119.   rs.FindFirst "GroupName Is Null"
  120.  
  121.   Do Until rs.NoMatch
  122.     StrText = rs![NodeName]
  123.     strNode = rs![nodeid]
  124.     FoldType = rs!FoldType
  125.     Set nd = TreeView1.Nodes.Add(, , StrText, StrText, FoldType)
  126.     nd.Tag = strNode
  127.     
  128.     bkMark = rs.Bookmark
  129.     AddChildren nd, rs
  130.     rs.Bookmark = bkMark
  131.     rs.FindNext "GroupName Is Null"
  132.     
  133.   Loop
  134.     
  135. CloseAccessDb
  136.     
  137.     For Each nd In TreeView1.Nodes
  138.         nd.Expanded = True
  139.         i = i + 1
  140.         FoldType = TreeView1.Nodes(i).Image
  141.         TreeView1.Nodes(i).Image = IIf(FoldType = 1, 2, FoldType)
  142.         
  143.     Next nd
  144.     
  145.   
  146.     AddList TreeView1.Nodes(1)
  147.     
  148.     'SubClassTreeView TreeView1, RGB(255, 255, 234)
  149.     SetWindowLong TreeView1.hWnd, GWL_EXSTYLE, WS_EX_LAYOUTRTL
  150.     SetWindowLong ListView1.hWnd, GWL_EXSTYLE, WS_EX_LAYOUTRTL
  151.     OldLong = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
  152.     
  153. End Sub
  154. Private Sub AddChildren(nodBoss As Node, rst As DAO.Recordset)
  155.  Dim nd As Node, StrText As String, bkMark As String, FoldType As Integer, strNode As Integer
  156.  
  157.  rst.FindFirst "[GroupName] ='" & nodBoss & "'"
  158.  
  159.  Do Until rst.NoMatch
  160.     strNode = rst![nodeid]
  161.     StrText = rst![NodeName]
  162.     FoldType = rst!FoldImage
  163.     Set nd = TreeView1.Nodes.Add(nodBoss, tvwChild, StrText, StrText, FoldType)
  164.     nd.Tag = strNode
  165.     bkMark = rst.Bookmark
  166.  
  167.     AddChildren nd, rst
  168.     rst.Bookmark = bkMark
  169.     rst.FindNext "[GroupName] ='" & nodBoss & "'"
  170.  
  171.  Loop
  172.  
  173. End Sub
  174. Private Sub AddList(nodBoss As String)
  175.  
  176.  Dim nd As Node, StrText As String, bkMark As String, FoldType As Integer, DocType As String
  177.  Dim LItem As ListItem, TempText As String, TempFold As Integer
  178.  
  179.  ConnectAccessDb
  180.  
  181. If nodBoss = "▐╟▄╞▄π╔ ╟ß▄╨▀φ" Then
  182.  Set rs = dbs.OpenRecordset("SELECT * FROM [Tree Table] WHERE FoldType=3 OR FoldType=4 OR FoldType=5 ", dbOpenDynaset, dbReadOnly)
  183. Else
  184.  Set rs = dbs.OpenRecordset("SELECT * FROM [Tree Table] WHERE (FoldType=3 OR FoldType=4 OR FoldType=5) And GroupName='" & nodBoss & "'", dbOpenDynaset, dbReadOnly)
  185. End If
  186.  
  187. Me.ListView1.ListItems.Clear
  188.  
  189. Do Until rs.EOF
  190.     
  191.     StrText = rs![NodeName]
  192.     FoldType = rs!FoldType
  193.    
  194.    If FoldType = 3 Then
  195.     Set LItem = ListView1.ListItems.Add(, , StrText, FoldType)
  196.    Else
  197.     Set LItem = ListView1.ListItems.Add(, , StrText, 4)
  198.    End If
  199.    
  200.     rs.MoveNext
  201. Loop
  202.  
  203.     CloseAccessDb
  204.    
  205. End Sub
  206.  
  207.